package com.jsu.user.controller.v1;

import com.baomidou.mybatisplus.extension.api.R;
import com.jsu.user.mapper.PrizeMapper;
import com.jsu.user.service.WebPrizeService;
import com.jsu.user.service.impl.WebPrizeServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.model.common.dtos.ResponseResult;
import org.example.model.user.pojo.Prize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/user/web/v1/prize")
@Api(tags = "积分奖品控制器")
public class WebPrizeController {
    @Autowired
    private WebPrizeServiceImpl webPrizeService;

//    @ApiOperation(value = "上传奖品图片")
//    @PostMapping("/upload")
//    public ResponseResult uploadPrizeImage(@RequestParam("file") String file){
//        return webPrizeService.uploadPrizeImage(file);
//    }

    @ApiOperation(value = "创建奖品信息")
    @PostMapping("/create")
    public ResponseResult createPrize(@RequestBody Prize prize){
        return webPrizeService.createPrize(prize);
    }
    @ApiOperation(value = "获取奖品信息")
    @GetMapping("/get")
    public ResponseResult getPrize(){
        log.info("获取奖品信息");
        return webPrizeService.getPrize();
    }

    @ApiOperation(value = "模糊查询")
    @GetMapping("/search/{keyword}")
    public ResponseResult searchPrize(@PathVariable String keyword){
        return webPrizeService.searchPrize(keyword);
    }

    @ApiOperation(value = "批量删除")
    @DeleteMapping("/batchDelete")
    public ResponseResult batchDeletePrize(@RequestBody Integer[] ids){
        return webPrizeService.batchDeletePrize(ids);
    }

    @ApiOperation(value = "更新奖品信息")
    @PostMapping("/update")
    public ResponseResult updatePrize(@RequestBody Prize prize){
        return webPrizeService.updatePrize(prize);
    }

    @ApiOperation(value = "删除奖品信息")
    @DeleteMapping("/delete/{id}")
    public ResponseResult deletePrize(@PathVariable int id){
        return webPrizeService.deletePrize(id);
    }

    @ApiOperation(value = "兑换奖品")
    @PostMapping("/exchange/{id}")
    public ResponseResult exchangePrize(@PathVariable int id){
        return webPrizeService.exchangePrize(id);
    }
}
